/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ocumed.presentation.termin;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.AbstractListModel;

/**
 *
 * @author apr3455
 */
public class VorschListModel extends AbstractListModel {

    ArrayList<Date> m_data = null; 
    SimpleDateFormat m_df = new SimpleDateFormat("dd.MM.yyyy HH:mm");
    
    public VorschListModel(int arztId, ArrayList<Date> dates){
        if(dates == null || (dates != null && dates.size() <= 0)){
            m_data = new ArrayList<Date>();
        } else {
            setTerminVorsch(dates, arztId, 0);
        }    
    }
    
    public int getSize() {
        if(m_data != null){
            return m_data.size();
        } else {
            return 0;
        }
    }

    public Object getElementAt(int pos) {
        if(m_data != null){
           return m_df.format(m_data.get(pos));
        } else {
           return "";
        }
    }

    
    void addSelectedTermin(Date d) {
        if(m_data != null && m_data.size() > 0){
            m_data.set(0, d);
        } else {
            m_data.add(d);
        }
        fireContentsChanged(this, 0, 0);
    }

    private void setTerminVorsch(ArrayList<Date> dates, int arztId, int behDauer) {
        m_data = dates;
        fireContentsChanged(this, 0, 0);
    }
    
}
